package cn.hongwei.mall.pms.vo;

import cn.hongwei.mall.pms.entity.AttrEntity;
import cn.hongwei.mall.pms.entity.SpuAttrValueEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author Great
 * @email 1224028994@qq.com
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SpuAttrValueVo extends SpuAttrValueEntity {

    private List<String> valueSelected;

    public void setValueSelected(List<String> valueSelected) {
        if(CollectionUtils.isEmpty(valueSelected)){
            return;
        }
        //逗号分隔，保存父类的属性值中
        this.setAttrValue(StringUtils.join(valueSelected,","));
    }
}
